from expression import *
from endvals import *


class ifthen(expression):
	def __init__(self,test,then,els):
		self.test = test
		self.then = then
		self.els = els
	def evaluate(self,env):
		test = self.test.evaluate(env)
		if(type(test) != type(1==1)):
			print "Error: Test in 'ifthen' should evaulate to a boolean"
		elif(test):
			return self.then.evaluate(env)
		else:
			return self.els.evaluate(env)

class whileloop(expression):
	def __init__(self,test,body):
		self.test = test
		self.body = body
	def evaluate(self,env):
		test = self.test.evaluate(env)
		if(type(test) != type(1==1)):
			print "Error: Test in 'whileloop' should evaulate to a boolean"
		elif(test == False):
			return void()
		else:
			self.body.evaluate(env)
			self.evaluate(env)
		
		
		
		
		
	
